﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Bxas.Utility.Message
{
    public class TemplateReader
    {
        public static string ReadFile(String FileName)
        {
            try
            {
                //String FILENAME = System.Web.HttpContext.Current.Server.MapPath(FileName);
                StreamReader objStreamReader = File.OpenText(FileName);
                String contents = objStreamReader.ReadToEnd();
                objStreamReader.Close();
                objStreamReader.Dispose();
                return contents;
            }
            catch
            {

            }
            return string.Empty;
        }

        public static string InitializeBody(string fileName, Dictionary<string, string> paramValues)
        {
            string body = ReadFile(fileName);

            foreach (string key in paramValues.Keys)
            {
                body = body.Replace("##" + key + "##", paramValues[key]);
            }
            return body;
        }
    }
}
